#ifndef ACCOUNT_H
#define ACCOUNT_H

#include "record.h"
#include "tools.h"
#include "book_service_data.h"

class Account   
{
public :
	string m_name;				//用户昵称
	unsigned int m_id;			//用户ID
	struct tm m_regTime;		//注册时间
	vector<Record> m_record; 	//借书记录
	unsigned int m_credit; 		//信用值 初始100 逾期归还一次-20,按时归还+10 最高100，低于40无法借书
	string m_passwd ; 			//用户密码
    unsigned int m_money; 		//剩余金额
	unsigned int m_deposit;  	//押金
	
	class Reserve
	{
	public:
		struct tm m_time;
		unsigned int m_bookId;
		unsigned int m_id;
	};
	
	vector<Reserve>  m_reserve;  //预约记录
	
	vector<unsigned int> m_vecList;
	vector<unsigned int> m_collection;
	
	Account(void);
	Account(const char* name,unsigned int id,struct tm& regTime,vector<Record>& record,unsigned int credit,const char* passwd,unsigned int money,unsigned int deposit,vector<unsigned int>& m_vecList,vector<unsigned int>& m_collection);
	
	//检查密码是否正确
	bool check_passwd(const char* passwd);
	//输入书号,约定天数借书，并生成一条借书记录存在容器中
	bool borrowBook(unsigned int book_id,unsigned int day);
	//输入书号还书加减信用值，并将之前的借书记录完善
	int returnBook(unsigned int book_id);

};

class AccountData
{
public :
	Account* load(unsigned int id);
	void save(Account& account);
};

#endif //ACCCOUNT_H
